﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using STT.Business;
using STT.Entities;
using STT.Layer.Connection;
using System.Data;

namespace STT.Admin.UserControls
{
    public partial class ucTimKiemGiangVien : System.Web.UI.UserControl
    {
        ToolBox tb = new ToolBox();
        protected void Page_Load(object sender, EventArgs e)
        {
            Methods.ChucVu(ref ddChucVu);
            Methods.ChuyenMon(ref ddChuyenMon);
            Methods.DonViGiangVien(ref ddDonVi, Session["TenDN"].ToString());
            Methods.NgoaiNgu(ref ddTrinhDoNgoaiNgu);
            //Methods.MonHoc(ref ddMonHoc);
            tb.GetDataTableByNguoiTao("TbLop_SelectAll", Session["TenDN"].ToString());
            Methods.HocVan(ref ddHocVan);
            //Methods.Lop(ref ddLopHoc);
            tb.GetDataTableByNguoiTao("TbMonHoc_SelectAll", Session["TenDN"].ToString());
            
        }


        protected void btTimKiem_Click(object sender, EventArgs e)
        {
            LoadDuLieu();
        }

        void LoadDuLieu()
        {
             DataTable dt= BTbGiangVien.SelectTeachersBySearch(new ETbGiangVien
            {
                MaGV = txtMaGiangVien.Text != "" ? txtMaGiangVien.Text : "",
                TenGV = txtTenGiangVien.Text,
                MaDonVi = int.Parse(ddDonVi.SelectedValue.ToString()),
                MaChucVu = int.Parse(ddChucVu.SelectedValue.ToString()),
                MaTDChuyenMon = int.Parse(ddChuyenMon.SelectedValue.ToString()),
                MaTDHocVan = int.Parse(ddHocVan.SelectedValue.ToString()),
            }, -1,//int.Parse(ddMonHoc.SelectedValue.ToString()),
            txtSoKhoaHocDay.Text != "" ? int.Parse(txtSoKhoaHocDay.Text) : -1,
            int.Parse(ddTrinhDoNgoaiNgu.SelectedValue.ToString()),
           -1,//int.Parse(ddLopHoc.SelectedValue.ToString())
           Session["TenDN"].ToString()
            );

            rpvGiangVien.Visible = true;
            rpvGiangVien.LocalReport.ReportPath = "RDLC\\TKGiangVien.rdlc";
            rpvGiangVien.LocalReport.DataSources.Clear();
            rpvGiangVien.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));
        }
    }
}